Fix compatibiity with calibre-web and standard ebooks#150
Open
mawise wants to merge 1 commit into
Open
Conversation
…andard ebooks' opds feeds Fix OpenSearch descriptor fetching and resolution The OPDS proxy previously attempted to fetch the OpenSearch descriptor at search time rather than during feed parsing. This failed on OPDS servers like calibre-web that required proxy authentication. This commit shifts the OpenSearch descriptor fetching into the feed parsing pipeline (in `serveAtom`), so that the true search template URL is injected directly into the proxy's rendered HTML. It correctly fetches the OSD files passing along any required credentials or custom User-Agents configured for that feed. Additionally, standard OPDS search queries are now cleanly supported by simply appending `?query=` to non-OSD endpoints. fix: support generic xml content types for opds feeds Standard Ebooks serves their OPDS search results with a generic `application/xml` or `text/xml` content type rather than the standard `application/atom+xml`. This causes opds-proxy to treat the results as a regular file download instead of intercepting and rendering them via HTML templates. This commit updates the `FormatByMimeType` mapping in `formats.go` to recognize `application/xml` and `text/xml` as ATOM feeds, ensuring these feeds are correctly processed and rendered. Actual book downloads (e.g., `application/epub+zip`) are unaffected. Tests have been added to verify that `FormatByMimeType` correctly handles both standard and generic XML content types, as well as book download formats. Update OpenSearch template parsing to prioritize acquisition types Update `ParseOpenSearchTemplate` to first prefer templates with `type="application/atom+xml;profile=opds-catalog;kind=acquisition"`. If not found, it falls back to standard OPDS types, then general Atom types, and finally any valid template as a last resort. Update tests accordingly to reflect the new priority. fix(opds): use prefix match for acquisition links Updates the link parsing logic to use strings.HasPrefix when checking the link relationship for acquisitions, supporting extensions like /open-access used in OPDS 1.2 tags. Also updates a test case to verify this behavior.
Author
|
Hi, I was excited when I came across your project! I had a couple issues fetching my authenticated calibre-web opds feed, and with the standard ebooks feed, so I resolved the incompatibilities. These changes are AI-assisted. I've got it running great on my fork, deployed and working for both opds sources. No pressure to merge these changes if you don't want to. Thanks for your work! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix OpenSearch descriptor fetching and resolution
The OPDS proxy previously attempted to fetch the OpenSearch descriptor at search time rather than during feed parsing. This failed on OPDS servers like calibre-web that required proxy authentication.
This commit shifts the OpenSearch descriptor fetching into the feed parsing pipeline (in
serveAtom), so that the true search template URL is injected directly into the proxy's rendered HTML. It correctly fetches the OSD files passing along any required credentials or custom User-Agents configured for that feed.Additionally, standard OPDS search queries are now cleanly supported by simply appending
?query=to non-OSD endpoints.fix: support generic xml content types for opds feeds
Standard Ebooks serves their OPDS search results with a generic
application/xmlortext/xmlcontent type rather than the standardapplication/atom+xml. This causes opds-proxy to treat the results as a regular file download instead of intercepting and rendering them via HTML templates.This commit updates the
FormatByMimeTypemapping informats.goto recognizeapplication/xmlandtext/xmlas ATOM feeds, ensuring these feeds are correctly processed and rendered. Actual book downloads (e.g.,application/epub+zip) are unaffected.Tests have been added to verify that
FormatByMimeTypecorrectly handles both standard and generic XML content types, as well as book download formats.Update OpenSearch template parsing to prioritize acquisition types
Update
ParseOpenSearchTemplateto first prefer templates withtype="application/atom+xml;profile=opds-catalog;kind=acquisition". If not found, it falls back to standard OPDS types, then general Atom types, and finally any valid template as a last resort. Update tests accordingly to reflect the new priority.fix(opds): use prefix match for acquisition links
Updates the link parsing logic to use strings.HasPrefix when checking the link relationship for acquisitions, supporting extensions like /open-access used in OPDS 1.2 tags. Also updates a test case to verify this behavior.